import utils from '@/libs/utils'
export default {
    mounted(el) {
        const oShowMoreTag = el.querySelector('.showMoreTag'),
            oPopTagMian = el.querySelector('.container'),
            body = document.querySelector('body');
        if (oShowMoreTag) {
            utils.addEvent(oShowMoreTag, 'click', function (e) {
                reset();
                oPopTagMian.className += ' active';
                e.stopPropagation();
                utils.addEvent(body, 'click', bodyClick);
            });
        }


        //解除上一个active的状态
        function reset() {
            const playlistTag = document.querySelector('.mod-playlist-tag'),
                oTagMian = playlistTag.getElementsByClassName('container active')[0];

            if (oTagMian) {
                oTagMian.className = 'container';
            }
        }

        // 点击其他地方解除active状态
        function bodyClick(e) {
            if (e.target.getAttribute('data-tagMore') !== "tagMore") {
                oPopTagMian.className = 'container';
                utils.removeEvent(body, 'click', bodyClick);
            }
        }
    }
}